// Directions
// Create two screens showing the same image
// Add a Hero Widget to the first screen
// Add a Hero Widget to the second screen
import 'package:flutter/material.dart';

class HeroDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MainScreen();
  }
}

class MainScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Main Screen'),
      ),
      body: GestureDetector(
        onTap: () {
          Navigator.push(context, MaterialPageRoute(builder: (_) {
            return DetailScreen();
          }, ));
          // Navigator.push(
          //   context,
          //   PageRouteBuilder(
          //     opaque: false,
          //     pageBuilder: (BuildContext context, _, __) {
          //       return DetailScreen();
          //     },
          //     transitionsBuilder:
          //         (___, Animation<double> animation, ____, Widget child) {
          //       return FadeTransition(
          //         opacity: animation,
          //         child: RotationTransition(
          //           turns:
          //               Tween<double>(begin: 0.5, end: 1.0).animate(animation),
          //           child: child,
          //         ),
          //       );
          //     },
          //   ),
          // );
        },
        child: Hero(
          tag: 'imageHero',
          child: Center(
            child: Image.network(
              'https://picsum.photos/250?image=9',
            ),
          ),
        ),
      ),
    );
  }
}

class DetailScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: GestureDetector(
        onTap: () {
          Navigator.pop(context);
        },
        child: Hero(
          tag: 'imageHero',
          child: Center(
            child: Image.network(
              'https://picsum.photos/250?image=9',
            ),
          ),
        ),
      ),
    );
  }
}
